<?
require_once "../php/Context.php";
require_once "../php/AdminInit.php";
if(!$admin->isAuthorize())
    echo "<script>document.location.href='../Admin.php';</script>";
?>
<!DOCTYPE HTML>
<html lang="en" ng-app="MainModule">
<head>
    <title>Home page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="../css/style.css" rel="stylesheet" type="text/css" media="all"/>
    <link rel="stylesheet" href="../css/bootstrap.min.css"/>
    <style>
        .header_bottom{
            width:430px;
            margin-left: 350px;
            margin-top: 50px;
        }
        .header h1{
            position: relative;
            top:30px;
            left: 350px;
        }
        .menu{
            height: 50px;
        }
        .product_table th{
            text-align: center;
            font-weight: bold;
            font-size: 20px;
        }
        .title_category{
            font-weight: bold;
            position: relative;
            top:5px;

        }
        .my_alert{
            width:220px;
        }

        .wrap{
            width:auto !important;
        }
        .container{
            width: 1800px;
        }

    </style>
</head>
<body>
<div class="wrap">
    <div class="header">
        <h1>>>>>Pages on the site:<<<<</h1>
        <div class="header_bottom">
            <div class="menu">
                <ul>
                    <li><a href="Admin.php">Home</a></li>
                    <li class="active"><a href="Product.php">Products</a></li>
                    <li><a href="News.php">News</a></li>
                    <li><a href="Contact.php">Contact</a></li>
                    <div class="clear"></div>
                </ul>
            </div>

            <div class="clear"></div>
        </div>
    </div>
    <div class="admin_panel" ng-controller="AdminCtrl">
        <div class="container">
            <div class="row">
                <div class="col-lg-4">
                        <h1>List products:</h1>
                        <div class="alert alert-success my_alert" ng-if="enableSuccess == true">
                            <a  class="alert-link">Success! Data is Save.</a>
                        </div>
                        <a href="" ng-click="ShowAddProduct()" class="btn btn-success">Add product</a>

                        <form  action="../php/AddProduct.php" method="post" enctype="multipart/form-data">
                            <table ng-if="enableAddProduct == true" class="product_table table table-striped product_table">
                                <tr>
                                    <td class="title_category">Title product: </td>
                                    <td><input type="text" class="form-control" ng-model="Product_title" /></td>
                                </tr>
                                <tr>
                                    <td class="title_category">Image: </td>
                                    <td><input type="file" name="file" class="form-control" onchange="angular.element(this).scope().fileNameChanged(event)"/></td>
                                </tr>
                                <tr>
                                    <td class="title_category">File_size: </td>
                                    <td><input type="text" class="form-control" ng-model="Product_file_size" /></td>
                                </tr>
                                <tr>
                                    <td class="title_category">Requirements: </td>
                                    <td><input type="text" class="form-control" ng-model="Product_Requirements" /></td>
                                </tr>
                                <tr>
                                    <td class="title_category">Languages: </td>
                                    <td><input type="text" class="form-control" ng-model="Product_Languages" /></td>
                                </tr>
                                <tr>
                                    <td class="title_category">Date added: </td>
                                    <td><input type="text" class="form-control" ng-model="Product_Date" /></td>
                                </tr>
                                <tr>
                                    <td class="title_category">Author: </td>
                                    <td><input type="text" class="form-control" ng-model="Product_Author" /></td>
                                </tr>
                                <tr>
                                    <td class="title_category">Homepage: </td>
                                    <td><input type="text" class="form-control" ng-model="Product_page" /></td>
                                </tr>
                                <tr>
                                    <td class="title_category">Description_preview: </td>
                                    <td><textarea class="form-control" ng-model="Product_Description_preview" rows="3" cols="3" >

                                        </textarea></td>
                                </tr>
                                <tr>
                                    <td class="title_category">Description: </td>
                                    <td><textarea class="form-control" ng-model="Product_Description" rows="3" cols="3"></textarea></td>
                                </tr>
                                <tr>
                                    <td class="title_category">Category: </td>
                                    <td>
                                        <select class="form-control" ng-options="category.Title for category in Categories" ng-model="Select_Category">
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td><a t class="btn btn-success"  ng-click="AddProduct(Product_title,Product_file_size,Product_Requirements,Product_Languages,Product_Date,Product_Author,Product_page,Product_Description_preview,Product_Description,Select_Category)">Send</a></td>
                                </tr>
                            </table>
                        </form>

                        </div>
                    <table class="table table-striped category_table" style="margin-top:40px;">
                        <thead>
                        <tr>
                            <th class="test">#</th>
                            <th>Title</th>
                            <th>Image_name</th>
                            <th>File_size</th>
                            <th>Requirements</th>
                            <th>Languages</th>
                            <th>Date_added</th>
                            <th>Author</th>
                            <th>Home page</th>
                            <th>Description_preview</th>
                            <th>Description</th>
                            <th>Category Id</th>
                            <th></th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="product in Products track by $index">
                            <td width="60" scope="row"><input type="text" class="form-control" value="{{product.Id}}" disabled/> </td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Title" /></td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Image"  /></td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.File_size"  /></td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Requirements"  /></td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Languages"  /></td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Date_added"  /></td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Author"  /></td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Homepage"  /></td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Description_preview"  /></td>
                            <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Description"  /></td>
                            <td><input class="form-control" type="text"  disabled ng-model="product.CategoryId"  /></td>
                            <td><a ng-click="DeleteProduct(product)" class="btn btn-success" style="cursor: pointer">Delete</a></td>
                            <td><a ng-hide="enableProduct == $index"  ng-click="editProduct($index)" class="btn btn-success" style="cursor: pointer">Edit</a>
                                <a ng-show="enableProduct == $index" ng-click="saveProduct(product)" class="btn btn-success" style="cursor: pointer">Save</a>
                            </td>
                            <td>
                                <a  ng-click="addToSlider(product)" class="btn btn-success" style="cursor: pointer">AddToSlider</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>

            </div>
        </div>
    </div>
    <script type="text/javascript" src="../js/jquery-2.1.3.min.js"></script>
    <script type="text/javascript" src="../js/angular.js"></script>
    <script type="text/javascript" src="/js/AngularControllers/AdminCtrl.js"></script>
    <script type="text/javascript" src="/js/AngularControllers/SliderCtrl.js"></script>
    <script type="text/javascript" src="/js/AngularControllers/ReadMoreCtrl.js"></script>
    <script type="text/javascript" src="/js/angularModules/mainModule.js"></script>
</body>
</html>

